/**
 * 
 */
package com.sst.social.networking.database;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * @author Rakesh
 * 
 */
public class DatabaseHelper extends SQLiteOpenHelper {

	private static DatabaseHelper o_instance = null;
	public static final String DATABASE_NAME = "AIOSocialNetworkingDB";
	public static final int DATABASE_VERSION = 1;
	public SQLiteDatabase o_db = null;
	public static final String AIOSN_LOGO = "aiosnlogo";

	public DatabaseHelper() {
		super(AndroidContext.getContext(), DATABASE_NAME, null,
				DATABASE_VERSION);
		o_db = getWritableDatabase();
	}

	public static DatabaseHelper getInstance() {
		if (o_instance == null) {
			o_instance = new DatabaseHelper();
		}
		return o_instance;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		final String[] creatStatments = new String[] { "create table "
				+ AIOSN_LOGO
				+ " (_id INTEGER PRIMARY KEY,title TEXT,logoimage BLOB)"

		};

		for (String sStmt : creatStatments) {
			db.execSQL(sStmt);
		}

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + AIOSN_LOGO);
		onCreate(db);
	}

	public SQLiteDatabase getDb() {
		return o_db;
	}

}